package com.jsm.tf.net.protocol.serialize;

import java.io.IOException;

public interface Serializer {
    <T> T deserialize(Class<T> clazz, byte[] bytes) throws IOException;

    <T> byte[] serialize(T object) throws IOException;

    enum Algorithm {
        JDK(new JDKSerializer()),
        Hessian(new HessianSerializer()),
        Json(new JsonSerializer()),
        Kryo(new KryoSerializer()),
        Gson(new GsonSerializer());
        private Serializer serializer;

        Algorithm(Serializer serializer) {
            this.serializer = serializer;
        }

        public Serializer getSerializer() {
            return serializer;
        }

        public void setSerializer(Serializer serializer) {
            this.serializer = serializer;
        }
    }
}
